import java.util.*;

/**
 * @author LKQ
 * @date 2022/6/4 21:17
 * @description 排序
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int maxWidthRamp(int[] nums) {
        int n = nums.length;
        Integer[] b = new Integer[n];
        for (int i = 0; i < n; i++) {
            b[i] = i;
        }
        // 升序排序
        Arrays.sort(b, (i, j) -> ((Integer) b[i]).compareTo(b[j]));
        int ans = 0;
        int m = n;
        for (int i : b) {
            ans = Math.max(ans, i - m);
            // 最前面的i，值肯定最小
            m = Math.min(m, i);
        }
        return ans;
    }
}
